package com.msr.utils;

import lombok.Data;

import java.util.List;

/**
 * @author tom
 * @version V1.0
 * @Package com.msr.utils
 * @date 2024/1/12 10:16
 * @Copyright © 株式会社多言语系统研究所
 *
 * 分页工具类
 */
@Data
public class PageUtils<T> {
    //1、每页条数
    private int pageSize;
    //2、当前页码
    private int pageIndex;
    //3、总页数
    private int pageCount;
    //4、总记录数
    private int totalCount;
    //5、每页的数据
    private List<T> records;

    public PageUtils(int pageSize, int pageIndex, int totalCount, List<T> records) {
        this.pageSize = pageSize;
        this.pageIndex = pageIndex;
        //计算总页数 = 总记录数 % 每页大小数
        this.pageCount = totalCount % pageSize == 0 ? (totalCount / pageSize) : (totalCount / pageSize+1);
        this.totalCount = totalCount;
        this.records = records;
    }
}
